package com.aaa.system.service.impl;

import com.aaa.entity.Role;
import com.aaa.system.dao.RoleDao;
import com.aaa.system.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: aaa-education-parent
 * @description:
 * @author: 闫克起2
 * @create: 2024-03-08 10:59
 **/
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;
    @Override
    public List<Role> selectAll() {
        List<Role> roles = roleDao.selectList(null);
        return roles;
    }

    @Override
    public List<String> selectByUserId(String userId) {
        return roleDao.selectByUserId(userId);
    }

    @Override
    @Transactional
    public void qrfp(String userId, String[] roleIds) {
        //1.删除该用户原来的角色
        roleDao.deleteByUserId(userId);
        //2. 添加新的角色
        roleDao.batchInsert(userId,roleIds);

    }
}
